home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 235 / Issue 235 - September 2007 - DPCS0907DVD.ISO / Extras / NetObjects Fusion / NOF10.exe / data1.cab / FSI / lib / nof / net / Ftp.js next >
Encoding:
Text File  |  2007-04-11  |  3.9 KB  |  120 lines

  1. /****i* SOURCE_FILE/INFO
  2.   *
  3.   * NAME
  4.   *  Ftp.js
  5.   *
  6.   * USAGE
  7.   *  Part of Netobjects JavaScript Library.
  8.   *
  9.   * COPYRIGHT
  10.   *  Copyright ⌐ 2000-2005 Website Pros, Inc.
  11.   *  All Rights Reserved.
  12.   *
  13.   *  This is an unpublished work protected by Website Pros, Inc.
  14.   *  as a trade secret, and is not to be used or disclosed except as
  15.   *  expressly provided in a written license agreement executed by
  16.   *  you and Website Pros, Inc.
  17.   *
  18.   *      <copyright@websitepros.com>
  19.   *
  20.   * NOTES
  21.   *  JavaScript code.
  22.   *
  23.   *****/
  24.  
  25. if (!IS_isModuleInitialized("IS.NOF.NET.Ftp"))
  26. {
  27.   
  28.   /****h* NOF_JavaScript_Library/NOF.NET.Ftp
  29.     *
  30.     * NAME
  31.     *  NOF.NET.Ftp
  32.     *
  33.     * DESCRIPTION
  34.     *
  35.     * The <code>Ftp</code> class is used to create an FTP connection and then download one or more files.
  36.     * 
  37.     * Usage sample:
  38.     * var ftpConn = new NOF.NET.Ftp();
  39.     * if (ftpConn.open("127.0.0.1", "userName", "userPassword", 21, false, "", "") == true) {
  40.     *   var successGetZip = ftpConn.getFile("myFiles/myZipFile.zip", "C:\\temp\\myZipFile.zip", true);
  41.     *   if (!successGetZip) {
  42.     *     var successGetEAR = ftpConn.getFile("myFiles/myEARFile.ear", "C:\\temp\\myEARFile.ear", true);
  43.     *     // ...
  44.     *   }
  45.     * }
  46.     * ftpConn.close();  
  47.     *
  48.     *
  49.     ****/
  50.   
  51.   /**
  52.     * Constructor    
  53.     */  
  54.   function NET_Ftp() {
  55.     this.__proto__ = NET_Ftp.prototype;        
  56.     this.ftp_comp = null;
  57.   }
  58.   {
  59.     var member = NET_Ftp.prototype;    
  60.     member.CLASS_NAME        = "NET.Ftp";
  61.       
  62.     var method = NET_Ftp.prototype;                                        
  63.  
  64.     /**            
  65.     * This function opens a connection to an FTP server. 
  66.     * The FTP connection is defined by 
  67.     * @param pServer (the FTP server address), 
  68.     * @param pUser (the user name for logging into the FTP server), 
  69.     * @param pPassword (the password for logging into the FTP server), 
  70.     * @param pPort (the port number, normally 21), 
  71.     * @param pPassive (true if a passive mode connection is required), 
  72.     * @param pProxyServer, and pProxyByPass (if a proxy server is used).
  73.     * 
  74.     * @return true if the connection was established.
  75.     **/        
  76.     method.open = function (/*String*/ pServer, /*String*/ pUser, /*String*/ pPassword, /*int*/ pPort, /*boolean*/ pPassive, /*String*/ pProxyServer, /*String*/ pProxyBypass) { 
  77.       var METHOD_NAME = "open";
  78.       if (this.ftp_comp == null) {
  79.         this.ftp_comp = new ActiveXObject(NOF.ProgId.FSIFtp);
  80.       }                
  81.       return this.ftp_comp.Open(pServer, pUser, pPassword, pPort, pPassive, pProxyServer, pProxyBypass);
  82.     }
  83.     
  84.     /**
  85.     * GetFile downloads a file using an FTP connection. 
  86.     * The FTP connection must already be established by calling the Open function. 
  87.     * @param pPath specifies the path of the file to download on the FTP server. 
  88.     * @param pLocalPath specifies the local path of the downloaded file. 
  89.     * @param pBinary if set to true the file will be downloaded as a binary file, 
  90.     * otherwise as an ascii file. 
  91.     * @return true if the file was successfully downloaded.
  92.     **/
  93.     method.getFile = function (/*String*/ pPath, /*String*/ pLocalPath, /*boolean*/ pBinary) {
  94.       return (this.ftp_comp != null) ? ( this.ftp_comp.GetFile(pPath, pLocalPath, pBinary) ) : false;
  95.     }
  96.     
  97.     /**
  98.     * This function closes a previously opened connection to an FTP server.
  99.     * This function should be called as soon as the download has been completed 
  100.     * in order not to tie up resources on the FTP server. 
  101.     * If no connection is currently open this function has no effect.
  102.     **/        
  103.     method.close = function () { 
  104.       var METHOD_NAME = "close";
  105.       if (this.ftp_comp != null) {
  106.         this.ftp_comp.Close();
  107.       }                                
  108.     }        
  109.     
  110.     /*
  111.     * release
  112.     */            
  113.     method.release = function () {
  114.       //this.close();
  115.       this.ftp_comp = null;
  116.     }
  117.   }
  118.   
  119.   NET.__proto__.Ftp = NET_Ftp;
  120. }